package com.tjetc.view.impl;

import com.tjetc.pojo.dto.HotelDTO;
import com.tjetc.pojo.dto.OrderDTO;
import com.tjetc.utils.ScannerUtils;
import com.tjetc.view.OrderCRUDPage;

import java.time.LocalDateTime;

/**
 * @Author: itda
 * @Date: 2024/5/11 14:05
 * @Description: OrderCRUDPageImpl
 */
public class OrderCRUDPageImpl implements OrderCRUDPage {
    @Override
    public OrderDTO save() {
        System.out.println("请输入房间id:");
        long roomId = ScannerUtils.sc.nextLong();
        System.out.println("请输入顾客id:");
        long guestId = ScannerUtils.sc.nextLong();
        LocalDateTime checkInDate = LocalDateTime.now();
        System.out.println("请输入该顾客住了几个小时:");
        int hour = ScannerUtils.sc.nextInt();
        LocalDateTime checkOutDate = checkInDate.plusHours(hour);
        return OrderDTO.builder()
                .roomId(roomId)
                .guestId(guestId)
                .checkInDate(checkInDate)
                .checkOutDate(checkOutDate)
                .build();
    }

    @Override
    public Long delete() {
        System.out.println("请输入要删除的订单id:");
        return ScannerUtils.sc.nextLong();
    }

    @Override
    public OrderDTO update() {
        System.out.println("请输入要修改的订单id:");
        long orderId = ScannerUtils.sc.nextLong();
        System.out.println("请输入房间id:");
        long roomId = ScannerUtils.sc.nextLong();
        System.out.println("请输入顾客id:");
        long guestId = ScannerUtils.sc.nextLong();
        LocalDateTime checkInDate = LocalDateTime.now();
        System.out.println("请输入该顾客住了几个小时:");
        int hour = ScannerUtils.sc.nextInt();
        LocalDateTime checkOutDate = checkInDate.plusHours(hour);
        return OrderDTO.builder()
                .id(orderId)
                .roomId(roomId)
                .guestId(guestId)
                .checkInDate(checkInDate)
                .checkOutDate(checkOutDate)
                .build();
    }
}
